import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
import './index.scss'
import request from '../../comment/request/request'
//新增收获地址页面
import { AtTabBar } from 'taro-ui'
export default class Index extends Component {

  config = {
    navigationBarTitleText: '订单',
    navigationBarBackgroundColor: '#6381F7',
    // navigationBarTitleText: 'WeChat',
    navigationBarTextStyle: 'white'
  }

  constructor(props) {
    super(props)
    this.state = {
      value: '',
      juli: true,
      current: 1,
      isOpened: false,
      AtInputNumbervalue: 1,
      checkedList: ['list1'],
      spList:[]
    }

  }

  handleChange(value) {
    this.setState({
      value1: value
    })
  }
  onSubmit(event) {
    console.log(event, 1)
    Taro.navigateTo({
      url: '../index.2/index'
    })
  }

  componentWillMount() {
    this.save()
  }
  //查询订单数量
  save = () => {
    let data = {
      gasStationId: "",
      owerPhone: "",
      page: 1,
      rows: 10
    }
    request._post(`/zhrq-web/gas/order/findPageList`, { ...data }).then(res => {
      //新增订单
      console.log(res, 54)
      if (res.rc === 0) {
        res.ret.items.forEach(item => {
        
        })
        this.setState({
          spList:res.ret.items
        })
      }
    })
  }

  componentDidMount() { }

  componentWillUnmount() { }

  handleClick(value) {
    this.setState({
      current: value
    })
    console.log(value)
    if (value == 0) {
      Taro.redirectTo({
        url: '../index/index'
      })
    }

    if (value == 2) {
      Taro.redirectTo({
        url: '../index.7/index'
      })
    }


  }

  onorder = () => {
    Taro.navigateTo({
      url: '../index.5/index'
    })
  }



  render() {

    var height
    wx.getSystemInfo({
      success: function (res) {
        console.log(res)
        height = res.screenHeight - 130 + 'px'
      }
    })
    return (
      <View className='index' >


      {
        this.state.spList && 
        this.state.spList.map((item) => {
          return (
            <View className='item' onClick={this.onorder}>
            <View className='item_L'>
              <Image
                className='Image'
                src='https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1759133402,2696021330&fm=26&gp=0.jpg'
              />
            </View>
  
            <View className='item_R'>
              <View className='item_top'>
                <View>
                  <Text>{item.gasStation.name}</Text>
                </View>
                <View className='Left'>
                  <Text>{item.status === 0?"订单已取消":item.status === 1?"订单已提交":item.status === 2?"商家已确认" :item.status === 3 ? "配送中":item.status === 4?"配送员已送达":"订单已完成"}</Text>
                </View>
              </View>
  
              <View className='item_model'>
                <Text>11.6kg燃气等3件商品</Text>
              </View>
  
              <View className='item_model'>
                <Text>下单时间 : 2018-12-19 18 : 28</Text>
              </View>
  
              <View className='item_bottom'>
                <Text>总价 : ¥190</Text>
              </View>
            </View>
  
  
          </View>
          )
        })
      }

      


        <AtTabBar
          fixed
          tabList={[
            { title: '订购', iconType: 'shopping-cart', text: 'new' },
            { title: '订单', iconType: 'shopping-bag', text: '100', max: '99' },
            { title: '投诉', iconType: 'mail' },
            { title: '我的', iconType: 'user', text: '100', max: '99' }
          ]}
          onClick={this.handleClick.bind(this)}
          current={this.state.current}
        />

      </View>
    )
  }
}

